package next.fire.spinus.logx.api.model;

/**
 * Created by daibing on 2019/10/17.
 */
public enum LevelEnum {
    ALL,
    DEBUG,
    INFO,
    WARN,
    ERROR
    ;

    public static LevelEnum get(String raw) {
        try {
            return valueOf(raw.toUpperCase());
        } catch (Exception e) {
            return null;
        }
    }

    public static LevelEnum getByOrdinal(int ordinal) {
        try {
            return values()[ordinal];
        } catch (Exception e) {
            return null;
        }
    }

    public static int getOrdinal(String raw) {
        try {
            return valueOf(raw.toUpperCase()).ordinal();
        } catch (Exception e) {
            return Integer.MAX_VALUE;
        }
    }

}
